# coding: utf-8

import os


def run_gen_model():
    """
    运行生成模块

        --schema: SCHEMA load tables from an alternate schema
        指定表，默认是全部的表
        --tables: TABLES tables to process (comma-separated, default: all)
        --noviews: ignore views
        --noclasses: don't generate classes, only tables
        --noindexes: don't generate index
        指定生成模型类文件
        --outfile: OUTFILE file to write output to (default: stdout)
    """
    mysql_url = "mysql://root:123456@10.10.10.72:3306/management"
    output_path = "D:\\workspace\\Python\\ak-web-frask\\app\\models\\model.py"
    table_name = ['files_upload', 'record', 'user_info']

    args = 'flask-sqlacodegen --noviews --noconstraints --noindexes %s --outfile %s --tables %s --flask' \
           % (mysql_url, output_path, ",".join(table_name))
    print(args)
    os.system(args)
    print('写入完成')


if __name__ == '__main__':
    run_gen_model()
